/**
 * Created by tanbingqin on 2019/7/17.
 */
import { messages } from "share/common";
import React from 'react'
import { connect } from 'react-redux'
import { Tabs } from 'antd'
const TabPane = Tabs.TabPane;
import AdminApproveListComp from "containers/setting/process-monitoring-platform/admin-approve-list";
import BatchTransferListComp from "containers/setting/process-monitoring-platform/batch-transfer-list";

class AdminApprove extends React.Component{
  constructor(props) {
    super(props);
    this.state = {
      tabs: [
        {key: 'approveList', name: messages('setting.key2121')/*流程管理*/},
        {key: 'transferList', name: messages('setting.key2122')/*批量转交*/}
      ],
      nowTab: 'approveList'
    }
  }

  componentDidMount(){}

  renderTabs() {
    const { tabs } = this.state;
    return (
      tabs.map(tab => {
        return <TabPane tab={tab.name} key={tab.key}/>
      })
    )
  }

  renderComponents = () => {
    const { nowTab } = this.state;
    switch(nowTab){
      case 'approveList':
        return <AdminApproveListComp />;
      case 'transferList':
        return <BatchTransferListComp />;
    }
  };

  //Tabs点击
  onChangeTabs = (key) => {
    this.setState({nowTab : key});
  };

  render() {
    const { nowTab } = this.state;
    return (
      <div>
        <Tabs type="card" onChange={this.onChangeTabs} activeKey={nowTab}>
          {this.renderTabs()}
        </Tabs>
        {this.renderComponents()}
      </div>
    )
  }
}

AdminApprove.contextTypes = {
  router: React.PropTypes.object
};

function mapStateToProps(state) {
  return {
    company: state.login.company,
    tenantMode: state.main.tenantMode
  }
}

export default connect(mapStateToProps)(AdminApprove)
